package pactera.tf.controller;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import pactera.tf.dataobj.ChatMsgDO;
import pactera.tf.excpetion.R;
import pactera.tf.service.ChatMsgService;

@RestController
public class PointToPointChatController {
	@Autowired
    ChatMsgService chatMsgService;
	
	
	 
    /**
     * 
    
     * <p>Title: lkfriends</p>  
    
     * <p>Description:查询两个好友间的历史聊天记录 </p>  
    
     * @param sendUserIdAndReciveUserId
     * @return  聊天信息的List集合 
     */
    @PostMapping("/chat/lkuschatmsg/{sendUserIdAndReciveUserId}")
    @ResponseBody public R listChatMsgBetweenfriends(@PathVariable("sendUserIdAndReciveUserId")String sendUserIdAndReciveUserId){
    	String[] idArr= sendUserIdAndReciveUserId.split("&");
    	String sendUserId = null;
    	String reciveUserId = null;
    	if (null != idArr && idArr.length == 2) {
    		 sendUserId = idArr[0];
             reciveUserId = idArr[1];
    	}
    	List<ChatMsgDO> list = chatMsgService.lookTwoUserMsg(new ChatMsgDO().setSendUserId(sendUserId).setReciveUserId(reciveUserId));
        return R.ok().data("chatInfo",list).message("聊天信息");
    }
}
